﻿using System;
using System.Runtime.InteropServices;
using static LinkControl;
using static System.Runtime.InteropServices.JavaScript.JSType;

[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe public static class Global
{
    public const int Total_Axis_Num = 4;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe struct SharedData
{
    public Handle kernel_handle;                                        // 内核句柄
    public Handle adapter_handle;                                       // 网络适配器句柄
    public Handle master_handle;                                        // 主站句柄
    public Handle dataset_handle;                                       // Dataset句柄
    public Handle dataset_callback_handle;                              // Dataset 的回调的句柄
    public Handle dataset_task_handle;                                  // Dataset Task 脚本的句柄
    public Handle timer_handle;                                         // timer句柄
    public Handle timer_callback_handle;                                // timer 的回调的句柄
    public Handle timer_task_handle;                                    // timer Task 脚本的句柄
    public Handle task_callback_handle;                                 // 执行 Task 脚本的回调的句柄
    public Handle task_handle;                                          // 执行 Task 回调的任务的句柄
    public Handle hMutex;                                               // Handle of the mutex for synchronized data access
    public int error;
    public int task_cpu;                                                // 要用于 Task 任务的 CPU 的索引
    public int abort;                                                   // 指示 Task 任务结束工作的标志
    public int count;
    public fixed int command_position[Global.Total_Axis_Num];           // 各轴目标位置
    public fixed int actual_position[Global.Total_Axis_Num];            // 各轴实际位置
    public fixed UInt16 statues[Global.Total_Axis_Num];                 // 各轴状态
    public fixed UInt16 control_words[Global.Total_Axis_Num];           // 各轴控制字
    public int command_type;                                            // 用户指令 1. enable 2. disable 3. move 4. home 5. stop
};
